<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var obj = {
      name: '李亚',
      sex: '女',
      age: 20,
      study: function () {
        console.log("学习");
      }
    }

    // 遍历 可枚举的属性
    for (const k in obj) {
      console.log(k);
      console.log(obj[k]);
    }

    //返回对象可枚举 属性的数组
    var arr = Object.keys(obj)
    console.log(arr);
    arr.forEach(function (v, i) {
      console.log(v, i);
    })
    // 返回对象的所有属性(包含不可枚举)的数组
    arr = Object.getOwnPropertyNames(obj);
    console.log(arr);
    delete obj.sex//删除属性(不用)
    console.log('sex' in obj);// 对象是否有属性
    console.log(obj);
  </script>
</body>

</html>